<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?> <!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>添加商品类型</title>
	<script type='text/javascript' src='http://localhost/dshop/hdphp/hdphp/Extend/Org/Jquery/jquery-1.8.2.min.js'></script>
<link href='http://localhost/dshop/hdphp/hdphp/../hdjs/css/hdjs.css' rel='stylesheet' media='screen'>
<script src='http://localhost/dshop/hdphp/hdphp/../hdjs/js/hdjs.js'></script>
<script src='http://localhost/dshop/hdphp/hdphp/../hdjs/js/slide.js'></script>
<script src='http://localhost/dshop/hdphp/hdphp/../hdjs/org/cal/lhgcalendar.min.js'></script>
<script type='text/javascript'>
		HOST = 'http://localhost';
		ROOT = 'http://localhost/dshop';
		WEB = 'http://localhost/dshop/index.php';
		URL = 'http://localhost/dshop/index.php?a=Admin&c=Goods&m=add&cid=62';
		HDPHP = 'http://localhost/dshop/hdphp/hdphp';
		HDPHPDATA = 'http://localhost/dshop/hdphp/hdphp/Data';
		HDPHPTPL = 'http://localhost/dshop/hdphp/hdphp/Lib/Tpl';
		HDPHPEXTEND = 'http://localhost/dshop/hdphp/hdphp/Extend';
		APP = 'http://localhost/dshop/index.php?a=Admin';
		CONTROL = 'http://localhost/dshop/index.php?a=Admin&c=Goods';
		METH = 'http://localhost/dshop/index.php?a=Admin&c=Goods&m=add';
		GROUP = 'http://localhost/dshop/hd';
		TPL = 'http://localhost/dshop/hd/Tshop/Admin/Tpl';
		CONTROLTPL = 'http://localhost/dshop/hd/Tshop/Admin/Tpl/Goods';
		STATIC = 'http://localhost/dshop/Static';
		PUBLIC = 'http://localhost/dshop/hd/Tshop/Admin/Tpl/Public';
		HISTORY = 'http://localhost/dshop/index.php?a=Admin&c=Goods&m=selectCategory';
		HTTPREFERER = 'http://localhost/dshop/index.php?a=Admin&c=Goods&m=selectCategory';
</script>
	<style type="text/css">
		#area{
			margin-bottom: 50px;
		}
	</style>
</head>
<body> 
	<form method="post" class="hd-form" enctype="multipart/form-data">
	<!-- <input type="text"> -->
	<div class="wrap">
				<div class="menu_list">
					<ul>
						<li>
							<a href="<?php echo U('index');?>">
								商品列表
							</a>
						</li>
						<li>
							<a href="javascript:;" class="action">
								添加商品
							</a>
						</li>
						<li>
							<a href="<?php echo U('addBrand');?>">
								添加品牌
							</a>
						</li>
					</ul>
				</div>

				<div class="tab">
					<ul class="tab_menu">
						<li lab="base"><a href="javascript:;">基本信息</a></li>
						<li lab="content"><a href="javascript:;">详细信息</a></li>
						<li lab="pic"><a href="javascript:;">图片</a></li>
					</ul>
					<div class="tab_content">
						<div id="base">
							<table class="table1">
								<tr>
									<th>名称</th>
									<td><input type="text" name="gname" class="w300"></td>
								</tr>
								<tr>
									<th>属性</th>
									<td>
										<label><input type="checkbox"   name="flag[]" value="推荐">推荐</label>
										<label><input type="checkbox"   name="flag[]" value="置顶">置顶</label>
									</td>
								</tr>
								<tr>
									<th>栏目</th>
									<td>
										<input type="hidden" name="cid" value="<?php echo $category['cid'];?>">
										<?php echo $category['cname'];?>
									</td>
								</tr>
								<tr>
									<th>属性</th>
									<td>
										<table>
											<?php $hd["list"]["goodsattr"]["total"]=0;if(isset($GoodsAttrForm) && !empty($GoodsAttrForm)):$_id_goodsattr=0;$_index_goodsattr=0;$lastgoodsattr=min(1000,count($GoodsAttrForm));
$hd["list"]["goodsattr"]["first"]=true;
$hd["list"]["goodsattr"]["last"]=false;
$_total_goodsattr=ceil($lastgoodsattr/1);$hd["list"]["goodsattr"]["total"]=$_total_goodsattr;
$_data_goodsattr = array_slice($GoodsAttrForm,0,$lastgoodsattr);
if(count($_data_goodsattr)==0):echo "";
else:
foreach($_data_goodsattr as $key=>$goodsattr):
if(($_id_goodsattr)%1==0):$_id_goodsattr++;else:$_id_goodsattr++;continue;endif;
$hd["list"]["goodsattr"]["index"]=++$_index_goodsattr;
if($_index_goodsattr>=$_total_goodsattr):$hd["list"]["goodsattr"]["last"]=true;endif;?>

											<tr>
												<th><?php echo $goodsattr['attr_name'];?></th>
												<td><?php echo $goodsattr['html'];?></td>
											</tr>
											<?php $hd["list"]["goodsattr"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
										</table>
									</td>
								</tr>
								<tr>
									<th>规格</th>
									<td>
										<table>
											<thead>
											<tr>
											<?php $hd["list"]["spec"]["total"]=0;if(isset($goodsSpec) && !empty($goodsSpec)):$_id_spec=0;$_index_spec=0;$lastspec=min(1000,count($goodsSpec));
$hd["list"]["spec"]["first"]=true;
$hd["list"]["spec"]["last"]=false;
$_total_spec=ceil($lastspec/1);$hd["list"]["spec"]["total"]=$_total_spec;
$_data_spec = array_slice($goodsSpec,0,$lastspec);
if(count($_data_spec)==0):echo "";
else:
foreach($_data_spec as $key=>$spec):
if(($_id_spec)%1==0):$_id_spec++;else:$_id_spec++;continue;endif;
$hd["list"]["spec"]["index"]=++$_index_spec;
if($_index_spec>=$_total_spec):$hd["list"]["spec"]["last"]=true;endif;?>

												<td><?php echo $spec['attr_name'];?></td>
											<?php $hd["list"]["spec"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>	
												<td>库存</td>
												<td>价格</td>
												<td>货号</td> 
												<td><a href="javascript:;" onclick="addStock(this)">添加（+）</a></td>
											</tr>
											</thead>
											<tbody id="tbody">
												<tr class="btn">
											<?php $hd["list"]["spec"]["total"]=0;if(isset($goodsSpec) && !empty($goodsSpec)):$_id_spec=0;$_index_spec=0;$lastspec=min(1000,count($goodsSpec));
$hd["list"]["spec"]["first"]=true;
$hd["list"]["spec"]["last"]=false;
$_total_spec=ceil($lastspec/1);$hd["list"]["spec"]["total"]=$_total_spec;
$_data_spec = array_slice($goodsSpec,0,$lastspec);
if(count($_data_spec)==0):echo "";
else:
foreach($_data_spec as $key=>$spec):
if(($_id_spec)%1==0):$_id_spec++;else:$_id_spec++;continue;endif;
$hd["list"]["spec"]["index"]=++$_index_spec;
if($_index_spec>=$_total_spec):$hd["list"]["spec"]["last"]=true;endif;?>

												<td><?php echo $spec['html'];?></td>
											<?php $hd["list"]["spec"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>	
												<td><input type="text" name="spec[stock][]" class="w100"></td>
												<td><input type="text" name="spec[price][]" class="w100"></td>
												<td><input type="text" name="spec[goods_sn][]"  class="w100"></td>
												<td><a href="javascript:;" onclick="removeStock(this)" style="color:red;">删除（-）</a></td>
											</tr>
											</tbody>
											<script type="text/javascript">
													function addStock(obj){
														var html=$('.btn').eq(0).clone();
														$('#tbody').append(html);
													}
													function removeStock(obj){
														var index=$('.btn').index();
														if(index>0){
															$(obj).parents(".btn").remove();
														}
													}

											</script>
										</table>
									</td>
								</tr>
								<tr>
									<th>品牌名称</th>
									<td>
									<select name="bid">
										<option value="">===选择===</option>
										<?php $hd["list"]["b"]["total"]=0;if(isset($brand) && !empty($brand)):$_id_b=0;$_index_b=0;$lastb=min(1000,count($brand));
$hd["list"]["b"]["first"]=true;
$hd["list"]["b"]["last"]=false;
$_total_b=ceil($lastb/1);$hd["list"]["b"]["total"]=$_total_b;
$_data_b = array_slice($brand,0,$lastb);
if(count($_data_b)==0):echo "";
else:
foreach($_data_b as $key=>$b):
if(($_id_b)%1==0):$_id_b++;else:$_id_b++;continue;endif;
$hd["list"]["b"]["index"]=++$_index_b;
if($_index_b>=$_total_b):$hd["list"]["b"]["last"]=true;endif;?>

										<option value="<?php echo $b['bid'];?>"><?php echo $b['bname'];?></option>
										<?php $hd["list"]["b"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
									</select>
									</td>
								</tr> 
								<!-- ________ -->
								<tr>
									<th>价格</th>
									<td><input type="text" name="price" class="w300"></td>
								</tr>
								<tr>
									<th>库存</th>
									<td><input type="text" name="stock" class="w300"></td>
								</tr>
								<!-- <?php if(!$goodsSpec){?> --><!-- <?php }?> -->
								<tr>
									<th>关键词</th>
									<td><input type="text" name="keywords" class="w300"></td>
								</tr>
								<tr>
									<th>描述</th>
									<td>
										<textarea id="area" name="description" class="w400 h100"></textarea>
									</td>
								</tr>
							</table>
						</div>
						<div id="content">
							<table class="table1">
								<tr>
									<th class="w100">内容</th>
									<td><script type="text/javascript" charset="utf-8" src="http://localhost/dshop/hdphp/hdphp/Extend/Org/Ueditor/ueditor.config.js"></script><script type="text/javascript" charset="utf-8" src="http://localhost/dshop/hdphp/hdphp/Extend/Org/Ueditor/ueditor.all.min.js"></script><script type="text/javascript">UEDITOR_HOME_URL="http://localhost/dshop/hdphp/hdphp/Extend/Org/Ueditor/"</script><script id="hd_body" name="body" type="text/plain"></script>
        <script type='text/javascript'>
        $(function(){
                var ue = UE.getEditor('hd_body',{
                imageUrl:'http://localhost/dshop/index.php?a=Admin&c=Goods&cid=62&m=ueditor_upload&g=Tshop&water=0&uploadsize=2000000&maximagewidth=false&maximageheight=false'//处理上传脚本
                ,zIndex : 0
                ,autoClearinitialContent:false
                ,initialFrameWidth:"100%" //宽度1000
                ,initialFrameHeight:"300" //宽度1000
                ,autoHeightEnabled:false //是否自动长高,默认true
                ,autoFloatEnabled:false //是否保持toolbar的位置不动,默认true
                ,maximumWords:2000 //允许的最大字符数
                ,readonly : false //编辑器初始化结束后,编辑区域是否是只读的，默认是false
                ,wordCount:true //是否开启字数统计
                ,imagePath:''//图片修正地址
                , toolbars:[
            ['fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe','insertcode', 'pagebreak', 'template', 'background', '|',
                'horizontal', 'date', 'time', 'spechars',  'wordimage', '|',
                'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                'print', 'preview', 'searchreplace']
            ]//工具按钮
                , initialStyle:'p{line-height:1em; font-size: 14px; }'
            });
        })
        </script></td>
								</tr>
								<tr>
									<th class="w100">服务</th>
									<td><input type="text" name='service'></td>
								</tr>
								<tr>
									<th class="w100">查看次数</th>
									<td><input type="text" name="click"></td>
								</tr>
								<tr>
									<th class="w100">发表时间</th>
									<td class="h150"><input type="text" id="addtime" name="addtime"></td>
								</tr>
								<script type="text/javascript">
									$('#addtime').calendar({format: 'yyyy/MM/dd HH:mm:ss'});
								</script>
							</table>
						</div>
						<div id="pic">
							<table class="table1">
								<tr>
									<th class="w100">首页图</th>
									<td ><input type="file" name="index_pic"></td>
								</tr>
								<tr>
									<th class="w100">列表图</th>
									<td ><input type="file" name="list_pic"></td>
								</tr>
								<tr>
									<th class="w100">内容页</th>
									<td >
										<ul id="button">
											<li><input  type="file" name="pic[]"><button type="button" id="but1"  class="hd-cancel">添加</button></li>
										</ul>

									</td> 
									<script type="text/javascript">
										$(function(){
											var data='<li><input type="file" name="pic[]"><button id="but" type="button"  class="hd-cancel">删除</button></li>';
											$("#but1").click(function(){
												$(this).parent().append(data);
											})
											$("#but").live('click',function(){
												$(this).parent('li').remove();
											})

										})
									</script>
								</tr>
							</table>
						</div>
					</div>

				</div>
			
	
				
				<div class='position-bottom'>
					<input type="submit" value="确定" class='hd-success'>
				</div>
	</div>
	</form>
</body>
</html>